package com.ishare.common.aop;

import com.ishare.common.utils.BeanUtils;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.util.StringUtils;

public class BeanWrapperCustomize extends BeanWrapperImpl {

    public BeanWrapperCustomize(Object object) {
        super(object);
    }

    public BeanWrapperCustomize setProperty(Object obj, String key){
        if (this.isWritableProperty(key)) {
            if (null != obj && !StringUtils.isEmpty(String.valueOf(BeanUtils.getValueByKey(obj, key))) && null == this.getPropertyValue(key)){
                this.setPropertyValue(key, BeanUtils.getValueByKey(obj,key));
            }
        }
        return this;
    }
}
